if exists(select name from sysobjects where name = 'sp_SanPhamGetAllByType')
	drop proc sp_SanPhamGetAllByType
go
/*-- =============================================
	Created by: HP
	Created on: 2014-03-15 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_SanPhamGetAllByType.sql
*/-- =============================================

CREATE PROCEDURE sp_SanPhamGetAllByType
@Top tinyint,
@Type tinyint
AS
BEGIN
	SELECT top(@Top)
		a.[Id],
		a.[TenSanPham],
		a.[MoTa],
		a.[NoiDung],
		a.[GiaBan],
		a.[GiaKM],
		a.[ThuTu],
		a.[Image],
		a.[Image1],
		a.[Image2],
		a.[Image3],
		a.[Image4],
		a.[Keywords],
		a.[Description],
		a.[Title],
		a.[NguoiTao],
		a.[NgayTao],
		a.[NguoiSua],
		a.[NgaySua],
		a.[TrangThai],
		a.[LoaiSanPhamId]
	FROM
        SanPham a where trangthai<>255 and (SanPham1=@Type or SanPham2=@Type or SanPham2=@Type)
END
GO


